package tilegame.sprites;

import graphics.Animation;

/**
A Grub is a Creature that moves slowly on the ground.
 */
public class Girl extends Element {

    private static final float JUMP_SPEED = -.95f;
    private boolean onGround;

    public Girl(Animation left, Animation right,
            Animation deadLeft, Animation deadRight) {
        super(left, right, deadLeft, deadRight);
        super.setLife(6);
    }

    public void jump(boolean forceJump) {
        if (onGround || forceJump) {
            onGround = false;
            setVelocityY(JUMP_SPEED);
        }
    }

    public void collideVertical() {
        // check if collided with ground
        if (getVelocityY() > 0) {
            onGround = true;
        }
                setVelocityY(0);
    }

    public void setY(float y) {
        // check if falling
        if (Math.round(y) > Math.round(getY())) {
            onGround = false;
        }
        super.setY(y);
    }

    public float getMaxSpeed() {
        return 0.05f;
    }
}
